//
//  XQHomeBigGuideView.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/19.
//

#import "XQHomeBigGuideView.h"
#import "XQHomeBigGuideCell.h"

@interface XQHomeBigGuideView()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,copy) NSArray *images;
@property (nonatomic,strong) UILabel *titleLb;
@property (nonatomic,strong) UITableView *tableView;
@end

@implementation XQHomeBigGuideView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initData];
        [self makeUI];
        [self makeConstraints];
    }
    return self;
}

- (void)initData {
    self.images = @[@"home_guide1",@"home_guide2",@"home_guide3"];
}

- (void)makeUI {
    [self addSubview:self.titleLb];
    [self addSubview:self.tableView];
}

- (void)makeConstraints {
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.equalTo(@16);
    }];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLb.mas_bottom).offset(10);
        make.left.equalTo(@16);
        make.right.equalTo(@-16);
        make.height.mas_equalTo(self.images.count * 104);
        make.bottom.equalTo(@0);
    }];
}

#pragma mark - UITableViewDelegate,UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.images.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    XQHomeBigGuideCell *cell = [tableView dequeueReusableCellWithIdentifier:@"XQHomeBigGuideCell" forIndexPath:indexPath];
    [cell setImageName:self.images[indexPath.row]];
    return cell;
}

#pragma mark - lazy

- (UILabel *)titleLb {
    if (!_titleLb) {
        _titleLb = [[UILabel alloc] init];
        _titleLb.text = @"Loan guide";
        _titleLb.font = [UIFont boldSystemFontOfSize:16];
        _titleLb.textColor = kBlackTextColor;
    }
    return _titleLb;
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] init];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = [UIColor clearColor];
        [_tableView registerClass:[XQHomeBigGuideCell class] forCellReuseIdentifier:@"XQHomeBigGuideCell"];
    }
    return _tableView;
}

@end
